package io.gitee.devaper.starlight.module.room.entity.vo

import io.gitee.devaper.starlight.common.entity.vo.*
import io.gitee.devaper.starlight.module.room.websocket.*

/**
 * 房间信息, 用来加入房间后用户获取的完整信息
 *
 * @param id 房间ID
 * @param creator 创建者
 * @param name 名称
 * @param users 用户信息列表
 * @param video 视频信息
 */
data class RoomVO(
    val id: String,
    val creator: UserVO,
    val name: String,
    val users: Collection<UserVO>,
    val video: VideoVO
) {

    companion object {

        /**
         * 将一个Room对象转为RoomVO对象
         *
         * @param room Room
         */
        fun valueOf(room: Room): RoomVO {
            return RoomVO(
                id = room.id,
                creator = UserVO.valueOf(room.creator),
                name = room.name,
                users = room.users.map { UserVO.valueOf(it) },
                video = VideoVO.valueOf(room.video)
            )
        }
    }

}
